package com.nbsaas.boot.store.rest.convert;

import com.nbsaas.boot.store.data.entity.StoreImage;
import com.nbsaas.boot.store.api.domain.request.StoreImageRequest;

import org.springframework.beans.BeanUtils;
import com.nbsaas.boot.rest.api.Converter;
import com.nbsaas.boot.utils.BeanDataUtils;
            import com.nbsaas.boot.shop.data.entity.Shop;
            import com.nbsaas.boot.store.data.entity.Store;

/**
* 商家图片请求对象转换成实体对象
*/

public class StoreImageEntityConvert  implements Converter<StoreImage, StoreImageRequest> {

    @Override
    public StoreImage convert(StoreImageRequest source) {
        StoreImage result = new StoreImage();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getShop()!=null){
                    Shop shop =new Shop();
                    shop.setId(source.getShop());
                    result.setShop(shop);
                    }
                    if(source.getStore()!=null){
                    Store store =new Store();
                    store.setId(source.getStore());
                    result.setStore(store);
                    }
        return result;
    }
}

